/// Author: Samle
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controllers/edit_books_controller.dart';
/// 特殊自定义组件
import '../../../../util/EasyInput.dart';

class EditBooksView extends GetView<EditBooksController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          leading: IconButton(
              icon: const Icon(Icons.arrow_back_ios),
              onPressed: Get.back
          ),
          elevation: 0,
          backgroundColor: Colors.black87,
          title: const Text("编辑词典"),
          centerTitle: true,
          actions: <Widget>[
            IconButton(
              icon: const Icon(
                Icons.save,
                color: Colors.white,
              ),
              onPressed: (){controller.saveData();},
            ),
          ]
      ),
      body: Container(
        padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
        child: ListView(
          children: [
            EasyInput(
              value: controller.name.text,
              keyboardType: "text",
              title: "名称",
              hintText: "请输入名称：",
              values: (value) {
                controller.name.text = value;
              },
            ),
            EasyInput(
              value: controller.path.text,
              keyboardType: "text",
              title: "地址",
              hintText: "请输入地址：",
              values: (value) {
                controller.path.text = value;
              },
            ),
            EasyInput(
              value: controller.cover.text,
              keyboardType: "text",
              title: "封面",
              hintText: "请输入封面：",
              values: (value) {
                controller.cover.text = value;
              },
            ),
            EasyInput(
              value: controller.num.text,
              keyboardType: "number",
              title: "数量",
              hintText: "请输入数量：",
              values: (value) {
                controller.num.text = value;
              },
            ),
            EasyInput(
              value: controller.content.text,
              keyboardType: "text",
              title: "说明",
              hintText: "请输入说明：",
              values: (value) {
                controller.content.text = value;
              },
            ),
            EasyInput(
              value: controller.source.text,
              keyboardType: "text",
              title: "来源",
              hintText: "请输入来源：",
              values: (value) {
                controller.source.text = value;
              },
            ),
          ],
        ),
      ),
    );
  }
}
